package yz.com.javautil.regex;

/**
 * 用于处理字符串内的特殊字符
 *
 * @author Administrator
 */
public class DealNameStringUtil {

    public static void main(String[] args) {
        String nameStr = "159元2个（劲省40元家庭装）;【腰包新科技】多功能强大小体积大容量高弹力腰包:;";
        System.out.println(dealNameStr(nameStr));
    }

    private static String dealNameStr(String sourceStr) {
        // 删除特殊字符　
        String specialChars = "[    \\\\,，。·.．;；:：、！?？@$%*^`~=+\\-&'\"|\\/]?";
        // 删除括号及括号内内描述性文字
        String regexStr0 = "[(].*[)]|[【].*[】]|[（].*[）]|[{].*[}]|[〈].*[〉]|[<].*[>]|[「].*[」]|[“].*[”]";
        // 删除规格相关
        String regexStr1 = "[一二三四五六七八九十0123456789]+[-]?[元双个对套袋箱]|\\d+(\\.\\d+)?(m|M|l|L|ml|ML|mL|g|G|kg|KG)?";
        return sourceStr.replaceAll(specialChars, "").replaceAll(regexStr0, "").replaceAll(regexStr1, "");
//        return sourceStr.replaceAll(regexStr0, "").replaceAll(regexStr1, "");
    }


}
